package org.jeecg.modules.basic.outstock.controller;

import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.basic.goods.entity.LwgyMaterialGoods;
import org.jeecg.modules.basic.material.entity.LwgyInStock;
import org.jeecg.modules.basic.outstock.entity.LwgyOutStock;
import org.jeecg.modules.basic.outstock.entity.LwgyOutStocks;
import org.jeecg.modules.basic.outstock.service.ILwgyOutStockService;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;

import org.jeecg.modules.basic.outstock.vo.LwgyOutStockPage;


import org.jeecg.common.system.base.controller.JeecgController;

import org.jeecg.modules.basic.outstocktype.entity.LwgyOutStockType;
import org.jeecg.modules.basic.outstocktype.service.ILwgyOutStockTypeService;
import org.jeecg.modules.basic.plan.entity.LwgyMaterialPlanGoods;
import org.jeecg.modules.basic.plan.entity.LwgyMaterialPlanapplication;
import org.jeecg.modules.basic.plan.entity.LwgyMaterialPlanapplications;
import org.jeecg.modules.basic.plan.vo.LwgyScoreSanitationPage;
import org.jeecg.modules.basic.storages.entity.LwgyStoragesNum;
import org.jeecg.modules.basic.storages.service.ILwgyStoragesNumService;
import org.jeecg.modules.basic.worker.entity.LwgyMaterialWorker;
import org.jeecg.modules.basic.worker.service.ILwgyMaterialWorkerService;
import org.jeecg.modules.hotel.arrangement.util.ExcelImportOut;
import org.jeecgframework.poi.excel.ExcelExportUtil;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;

 /**
 * @Description: 出库管理表
 * @Author: jeecg-boot
 * @Date:   2021-04-02
 * @Version: V1.0
 */
@Api(tags="出库管理表")
@RestController
@RequestMapping("/outstock/lwgyOutStock")
@Slf4j
public class LwgyOutStockController extends JeecgController<LwgyOutStock, ILwgyOutStockService> {
	@Autowired
	private ILwgyOutStockService lwgyOutStockService;

	 @Autowired
	 private ILwgyOutStockTypeService lwgyOutStockTypeService;

	 @Autowired
	 private ILwgyStoragesNumService lwgyStoragesNumService;


	 @Autowired
	 private ILwgyMaterialWorkerService lwgyMaterialWorkerService;

	 @Autowired
	 private ISysBaseAPI sysBaseAPI;


	
	/**
	 * 分页列表查询
	 *
	 * @param lwgyOutStock
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	@AutoLog(value = "出库管理表-分页列表查询")
	@ApiOperation(value="出库管理表-分页列表查询", notes="出库管理表-分页列表查询")
	@GetMapping(value = "/list")
	public Result<?> queryPageList(LwgyOutStock lwgyOutStock,
								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
								   HttpServletRequest req) {
		QueryWrapper<LwgyOutStock> queryWrapper = QueryGenerator.initQueryWrapper(lwgyOutStock, req.getParameterMap());
		LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
		List<String> roles = sysBaseAPI.getRolesByUsername(sysUser.getUsername());
		if (!roles.contains("admin")) {
			queryWrapper.eq(" writer_id",sysUser.getUsername());
		}
		Page<LwgyOutStock> page = new Page<LwgyOutStock>(pageNo, pageSize);
		IPage<LwgyOutStock> pageList = lwgyOutStockService.page(page, queryWrapper);
		return Result.OK(pageList);
	}
	 @AutoLog(value = "lwgy_material_planapplication-自定义分页列表查询")
	 @ApiOperation(value = "lwgy_material_planapplication-自定义分页列表查询", notes = "lwgy_material_planapplication-自定义分页列表查询")
	 @GetMapping(value = "/list2")
	 public Result<?> queryCustomersList(LwgyOutStocks lwgyOutStocks,
										 @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
										 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
										 @RequestParam(name="id",required=true) String id,
										 HttpServletRequest req) {
		 QueryWrapper<LwgyOutStocks> queryWrapper = QueryGenerator.initQueryWrapper(lwgyOutStocks, req.getParameterMap());
		 Page<LwgyOutStocks> page = new Page<>(pageNo, pageSize);
		 IPage<LwgyOutStocks> pageList = lwgyOutStockService.queryPageCustomer(page, queryWrapper,id);
		 return Result.OK(pageList);
	 }
	
	/**
	 *   添加
	 *
	 * @param lwgyOutStock
	 * @return
	 *//*
	@AutoLog(value = "出库管理表-添加")
	@ApiOperation(value="出库管理表-添加", notes="出库管理表-添加")
	@PostMapping(value = "/add")
	public Result<?> add(@RequestBody LwgyOutStock lwgyOutStock) {
		String stockno="";
		LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
				"yyyyMMddHHmmss-SSS");
		stockno = "PP" + simpleDateFormat.format(new Date());
		lwgyOutStock.setStockNo(stockno);
		lwgyOutStock.setOutState("0");
		lwgyOutStock.setReviewState("0");
		lwgyOutStock.setProgress("0%");
		lwgyOutStock.setWriterId(sysUser.getUsername());
		lwgyOutStock.setWriteTime(new Date());

		lwgyOutStockService.save(lwgyOutStock);
		if (lwgyOutStock != null &&lwgyOutStock.getId() != null) {
			LwgyOutStockType lwgyOutStocktype=new LwgyOutStockType();
			lwgyOutStocktype.setApplyId(lwgyOutStock.getId());
			lwgyOutStocktype.setGoodsId(lwgyOutStock.getGoodsId());
			lwgyOutStocktype.setApplyNum(lwgyOutStock.getApplyNum());
			lwgyOutStocktypeService.save(lwgyOutStocktype);
		}
		return Result.OK("添加成功！");
	}
	
	*//**
	 *  编辑
	 *
	 * @param lwgyOutStock
	 * @return
	 *//*
	@AutoLog(value = "出库管理表-编辑")
	@ApiOperation(value="出库管理表-编辑", notes="出库管理表-编辑")
	@PutMapping(value = "/edit")
	public Result<?> edit(@RequestBody LwgyOutStock lwgyOutStock) {
		lwgyOutStockService.updateById(lwgyOutStock);
		return Result.OK("编辑成功!");
	}
	
	*//**
	 *   通过id删除
	 *
	 * @param id
	 * @return
	 *//*
	@AutoLog(value = "出库管理表-通过id删除")
	@ApiOperation(value="出库管理表-通过id删除", notes="出库管理表-通过id删除")
	@DeleteMapping(value = "/delete")
	public Result<?> delete(@RequestParam(name="id",required=true) String id) {
		lwgyOutStockService.removeById(id);
		return Result.OK("删除成功!");
	}
	
	*//**
	 *  批量删除
	 *
	 * @param ids
	 * @return
	 *//*
	@AutoLog(value = "出库管理表-批量删除")
	@ApiOperation(value="出库管理表-批量删除", notes="出库管理表-批量删除")
	@DeleteMapping(value = "/deleteBatch")
	public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
		this.lwgyOutStockService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}
	
	*//**
	 * 通过id查询
	 *
	 * @param id
	 * @return
	 *//*
	@AutoLog(value = "出库管理表-通过id查询")
	@ApiOperation(value="出库管理表-通过id查询", notes="出库管理表-通过id查询")
	@GetMapping(value = "/queryById")
	public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
		LwgyOutStock lwgyOutStock = lwgyOutStockService.getById(id);
		if(lwgyOutStock==null) {
			return Result.error("未找到对应数据");
		}
		return Result.OK(lwgyOutStock);
	}*/

	 /**
	  *   出库(20230222修改未改完)
	  *
	  * @param
	  * @return
	  */
	 @AutoLog(value = "物料出库表-出库")
	 @ApiOperation(value="物料出库-出库", notes="物料出库-出库")
	 @PostMapping(value = "/changeSureState")
	 public Result<?> changeSureState(@RequestBody LwgyOutStockPage lwgyOutStockPage) {
		 LwgyOutStock lwgyOutStock = new LwgyOutStock();
		 BeanUtils.copyProperties(lwgyOutStockPage, lwgyOutStock);
		 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
		 String id=lwgyOutStockPage.getId();
		 String applyId=lwgyOutStockPage.getApplyId();
		 String goodsId = lwgyOutStockPage.getGoodsId();
		 String applyNum=lwgyOutStockPage.getApplyNum();
		 String outNum=lwgyOutStockPage.getApplyNum();
		 String [] strs = id.split(",");
		 String [] str =applyId.split(",");
		 String [] str1=goodsId.split(",");
		 String []str2=applyNum.split(",");
		 String []str3=outNum.split(",");
		 List<String>lists=Arrays.asList(strs);
		 List<String> list = Arrays.asList(str);
		 List<String> list1 = Arrays.asList(str1);
		 List<String> list2 = Arrays.asList(str2);
		 List<String> list3 = Arrays.asList(str3);
		 if (lwgyOutStockPage != null &&lwgyOutStockPage.getId() != null) {
		 	System.out.println("走这里了！！！！");
		 	for(int i=0;i<lists.size();i++){
				LwgyOutStockType lwgyOutStockType=new LwgyOutStockType();
				List<LwgyOutStockType> list11=lwgyOutStockTypeService.queryPageList(list.get(0));
				lwgyOutStockType= list11.get(0);
				lwgyOutStockType.setOutDate(new Date());
				lwgyOutStockType.setId(lists.get(i));//id
				lwgyOutStockType.setApplyId(list.get(i));//applyId
				lwgyOutStockType.setGoodsId(list1.get(i));//goodsId
				lwgyOutStockType.setApplyNum(list2.get(i));//applyNum
				lwgyOutStockType.setOutNum(new BigDecimal(list3.get(i)));//outNum
				lwgyOutStockType.setMark("1");
				lwgyOutStockType.setOuterId(sysUser.getUsername());
				lwgyOutStockTypeService.updateById(lwgyOutStockType);
			}

		 }
		 LwgyStoragesNum lwgyStoragesNum=new LwgyStoragesNum();
		 List<LwgyStoragesNum> list12=lwgyStoragesNumService.queryPageList(lwgyOutStockPage.getGoodsId(),lwgyOutStockPage.getName());
		 System.out.println("list12:"+list12);
		 if(list.size()>=1){
			 lwgyStoragesNum = list12.get(0);
				 BigDecimal a = lwgyOutStockPage.getOutNum();
				 System.out.println("aaaa:"+a);
				 BigDecimal b = lwgyStoragesNum.getNum();
				 System.out.println("bbbbbb:"+b);
				 BigDecimal c = b.subtract(a);
				 System.out.println("ccccc:"+c);
				 lwgyStoragesNum.setNum(c);
				 lwgyStoragesNumService.updateById(lwgyStoragesNum);//库存修改
		 }
		 LwgyMaterialWorker wgoods= new LwgyMaterialWorker();
		 List<LwgyMaterialWorker> wgh=lwgyMaterialWorkerService.queryPageList(lwgyOutStockPage.getGoodsId());
		 System.out.println("wghhhh:"+wgh);
	 	if(wgh.size()>0){
	 		System.out.println("走这里了！");
			 wgoods=wgh.get(0);
			 BigDecimal a=wgoods.getApplyNum();
			 BigDecimal b=lwgyOutStockPage.getOutNum();
			 BigDecimal wnum=a.add(b);
			 wgoods.setApplyNum(wnum);
			 wgoods.setApplyDate(new Date());
			 wgoods.setUserId(sysUser.getUsername());
			 wgoods.setApplyId(sysUser.getUsername());
			 lwgyMaterialWorkerService.updateById(wgoods);
		 }else{
	 		System.out.println("走这里了吗！！！！！");
			 wgoods.setUserId(sysUser.getUsername());
			 wgoods.setGoodsId(lwgyOutStockPage.getGoodsId());
			 wgoods.setApplyNum(lwgyOutStockPage.getOutNum());
			 wgoods.setSpecs(lwgyOutStockPage.getSpecs());
			 wgoods.setMeasurement(lwgyOutStockPage.getMeasurement());
			 wgoods.setPrice(lwgyOutStockPage.getPrice());
			 wgoods.setApplyDate(new Date());
			 wgoods.setApplyId(sysUser.getUsername());
			 lwgyMaterialWorkerService.save(wgoods);
		 }

		 List<Map<String,Object>>list10=lwgyOutStockTypeService.queryPageSureList(list.get(0));
		 System.out.println("list11111"+list10);
		 Map<String,Object>map = list10.get(0);
		 double a = Double.valueOf(map.get("progress").toString());
		 System.out.println("aaaaa:"+a);
		 lwgyOutStock.setProgress(a);
		 lwgyOutStock.setOutState("1");
		 lwgyOutStock.setOutStockDate(new Date());
		 lwgyOutStockService.changeState(list.get(0),a);
		 return Result.OK("出库成功！");
	 }



	 /**
	  *   添加
	  *
	  * @param
	  * @return
	  */
	 @AutoLog(value = "物料管理-添加")
	 @ApiOperation(value="物料管理-添加", notes="物料管理-添加")
	 @PostMapping(value = "/add")
	 public Result<?> add(@RequestBody LwgyOutStockPage lwgyOutStockPage) {
		 String stockno="";
		 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
		 SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
				 "yyyyMMddHHmmss-SSS");
		 stockno = "PP" + simpleDateFormat.format(new Date());
		 LwgyOutStock lwgyOutStock = new LwgyOutStock();
		 BeanUtils.copyProperties(lwgyOutStockPage, lwgyOutStock);
		 lwgyOutStock.setStockNo(stockno);
		 lwgyOutStock.setOutState("0");
		 lwgyOutStock.setReviewsState("0");
		 lwgyOutStock.setProgress((double)0);
		 lwgyOutStock.setWriterId(sysUser.getUsername());
		 lwgyOutStock.setWriteTime(new Date());
		 lwgyOutStockService.saveMain(lwgyOutStock, lwgyOutStockPage.getLwgyOutStockTypList());
		 String goodsId =lwgyOutStockPage.getGoodsId();
		 System.out.println("11111122:"+goodsId);
		 String applyNum=lwgyOutStockPage.getApplyNum();
		 System.out.println("11111122333:"+applyNum);
		 String [] str = goodsId .split(",");
		 String [] str1=applyNum.split(",");
		 List<String> list = Arrays.asList(str);
		 List<String> list1 = Arrays.asList(str1);
		 if (null!=list&&list.size()>0){
			 for (int i =0;i< list.size();i++){
				 LwgyOutStockType lwgyOutStockType=new LwgyOutStockType();
				 lwgyOutStockType.setApplyId(lwgyOutStock.getId());
				 lwgyOutStockType.setGoodsId(list.get(i));
				 lwgyOutStockType.setApplyNum(list1.get(i));
				 lwgyOutStockType.setApplyDate(new Date());
				 lwgyOutStockType.setMark("0");
				 lwgyOutStockTypeService.save(lwgyOutStockType);
			 }
		 }
		 return Result.OK("添加成功！");
	 }

	 /**
	  *  编辑
	  *
	  * @param
	  * @return
	  */
	 @AutoLog(value = "物料管理-编辑")
	 @ApiOperation(value="物料管理-编辑", notes="物料管理-编辑")
	 @PutMapping(value = "/edit")
	 public Result<?> edit(@RequestBody LwgyOutStockPage lwgyOutStockPage) {
		 LwgyOutStock lwgyOutStock = new LwgyOutStock();
		 BeanUtils.copyProperties(lwgyOutStockPage, lwgyOutStock );
		 LwgyOutStock lwgyOutStockEntity = lwgyOutStockService
				 .getById(lwgyOutStock.getId());
		 if(lwgyOutStockEntity==null) {
			 return Result.error("未找到对应数据");
		 }
		 lwgyOutStockService.updateMain(lwgyOutStock,  lwgyOutStockPage.getLwgyOutStockTypList());
		 return Result.OK("编辑成功!");
	 }



	 /**
	  *   通过id删除
	  *
	  * @param id
	  * @return
	  */
	 @AutoLog(value = "出库管理-通过id删除")
	 @ApiOperation(value="出库管理-物料管理删除", notes="出库管理-通过id删除")
	 @DeleteMapping(value = "/delete")
	 public Result<?> delete(@RequestParam(name="id",required=true) String id) {
		 lwgyOutStockService.delMain(id);
		 return Result.OK("删除成功!");
	 }

	 /**
	  *  批量删除
	  *
	  * @param ids
	  * @return
	  */
	 @AutoLog(value = "出库管理-批量删除")
	 @ApiOperation(value="出库管理-批量删除", notes="出库管理-批量删除")
	 @DeleteMapping(value = "/deleteBatch")
	 public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
		 this.lwgyOutStockService.delBatchMain(Arrays.asList(ids.split(",")));
		 return Result.OK("批量删除成功！");
	 }

	 /**
	  * 通过id查询
	  *
	  * @param id
	  * @return
	  */
	 @AutoLog(value = "出库管理-通过id查询")
	 @ApiOperation(value="出库管理-通过id查询", notes="出库管理-通过id查询")
	 @GetMapping(value = "/queryById")
	 public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
		 LwgyOutStock lwgyScoreSanitation = lwgyOutStockService.getById(id);
		 if(lwgyScoreSanitation==null) {
			 return Result.error("未找到对应数据");
		 }
		 return Result.OK(lwgyScoreSanitation);

	 }

	 /**
	  * 通过id查询
	  *
	  * @param id
	  * @return
	  */
	 @AutoLog(value = "物料管理通过主表ID查询")
	 @ApiOperation(value="物料管理主表ID查询", notes="物料管理-通主表ID查询")
	 @GetMapping(value = "/queryLwgyTargetTypeByMainId")
	 public Result<?> queryLwgyTargetTypeListByMainId(@RequestParam(name="id",required=true) String id) {
		 List<LwgyOutStockType> lwgyOutStockTypeList = lwgyOutStockTypeService.selectByMainId(id);
		 return Result.OK(lwgyOutStockTypeList);
	 }

    /**
    * 导出excel
    *
    * @param request
    * @param lwgyOutStock
    */
   /* @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, LwgyOutStock lwgyOutStock) {
        return super.exportXls(request, lwgyOutStock, LwgyOutStock.class, "出库管理表");
    }*/
	 /**
	  * 导出excel
	  *
	  * @param request
	  * @param
	  */
	 @RequestMapping(value = "/importExcelUrlToOut")
	 public void importExcelUrlToOut(HttpServletRequest request, HttpServletResponse response, LwgyOutStocks lwgyOutStocks) throws IOException {
		 //获取信息。
		 List<LwgyOutStocks> lwgyOutStock = lwgyOutStockService.queryPageExportListCustom(lwgyOutStocks);
		 System.out.println("677898989989:"+lwgyOutStock);
		 IntSummaryStatistics resultNum = lwgyOutStock.stream().mapToInt((item) -> Integer.parseInt(item.getStudentCampus())).summaryStatistics();
		 Integer info = resultNum.getMax();
		 LinkedHashMap<String, List<LwgyOutStocks>> lwgyBaseOut = lwgyOutStock.stream()
				 .collect(Collectors.groupingBy(LwgyOutStocks::getId,LinkedHashMap::new, Collectors.toList()));
		 List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>();

		 lwgyBaseOut.forEach((key, value) -> {
			 Map<String, Object> map1 = new HashMap<>();
			 List<LwgyOutStocks> list = value;

			 list.stream().forEach(p -> {
				 map1.put("studentCampuss", p.getStudentCampuss());
				 map1.put("name", p.getName());
				 map1.put("writerId", p.getWriterId());
				 map1.put("stockNo", p.getStockNo());
				 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				 String formattedDate = sdf.format(p.getWriteTime());
				 /* map1.put("writerTime", p.getWriteTime());*/
				 map1.put("writerTime", formattedDate);
				 map1.put("itemName",p.getItemName());
				 map1.put("measurement", p.getMeasurement());
				 map1.put("price", p.getPrice());
				 map1.put("specs", p.getSpecs());
				 map1.put("applyNum",p.getApplyNum());
				 map1.put("outNum",p.getOutNum());
				 map1.put("checkNote",p.getCheckNote());

				 for (int i = 1; i <= info; i++) {
					 if (p.getStudentCampus().contains(i + "")) {
						 map1.put(i + "itemName", p.getItemName());
						 map1.put(i + "measurement", p.getMeasurement());
						 map1.put(i + "price", p.getPrice());
						 map1.put(i + "specs", p.getSpecs());
						 map1.put(i + "applyNum", p.getApplyNum());
						 map1.put(i + "outNum", p.getOutNum());
						 map1.put(i + "checkNote", p.getCheckNote());
					 }
				 }
			 });
			 dataList.add(map1);
		 });
		 //获取最大category
		 int weeksize = info;
		 List<ExcelExportEntity> entityList = ExcelImportOut.ExcelImportUtil(weeksize);
		 Workbook wb = ExcelExportUtil.exportExcel(new ExportParams(null, "sheetName"), entityList, dataList);
		 try {
			 String fileName = "用户信息表";
			 OutputStream output = response.getOutputStream();
			 response.setContentType("application/vnd.ms-excel;charset=utf-8");
			 response.setCharacterEncoding("utf-8");
			 response.setHeader("Content-disposition", "attachment;filename=" + new String(fileName.getBytes("gbk"), "utf-8") + ".xls");
			 wb.write(output);
			 output.close();
		 } catch (Exception e) {
			 e.printStackTrace();
		 }
	 }

    /**
      * 通过excel导入数据
    *
    * @param request
    * @param response
    * @return
    */
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
        return super.importExcel(request, response, LwgyOutStock.class);
    }
	 /**
	  * 已通过状态
	  *
	  * @param
	  * @return
	  */
	 @AutoLog(value = "审核状态")
	 @ApiOperation(value = "审核", notes = "审核")
	 @PutMapping(value = "/changeStateUrl")
	 public Result<?>changeState(@RequestBody LwgyOutStock lwgyOutStock) {
	 	System.out.println("1111112223331345677:"+lwgyOutStock);
		 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();//登录人
		 lwgyOutStock.setReviewsState("1");
		 lwgyOutStock.setCheckNote(lwgyOutStock.getCheckNote());
		 lwgyOutStock.setCheckId(sysUser.getUsername());//审核人
		 lwgyOutStock.setCheckTime(new Date());//审核时间
		 lwgyOutStockService.updateById(lwgyOutStock);
		 return Result.OK("保存成功!");
	 }

	 /**
	  * 未通过状态
	  *
	  * @param
	  * @return
	  */
	 @AutoLog(value = "审核状态")
	 @ApiOperation(value = "审核", notes = "审核")
	 @PutMapping(value = "/changeNoStateUrl")
	 public Result<?>changeNoState(@RequestBody LwgyOutStock lwgyOutStock) {
		 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();//登录人
		 lwgyOutStock.setReviewsState("2");
		 lwgyOutStock.setCheckId(sysUser.getUsername());//审核人
		 lwgyOutStock.setCheckTime(new Date());//审核时间
		 lwgyOutStockService.updateById(lwgyOutStock);
		 return Result.OK("保存成功!");
	 }


}
